package ac.beiwo.baas;

import ac.beiwo.baas.common.interceptor.AdminInterceptor;
import ac.beiwo.baas.common.interceptor.AuthInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@SpringBootApplication
public class Main extends WebMvcConfigurerAdapter {

    @Autowired
    private AuthInterceptor authInterceptor;
    @Autowired
    private AdminInterceptor adminInterceptor;

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //授权拦截器
        registry.addInterceptor(authInterceptor).excludePathPatterns("/file/**");
        //管理员权限拦截器
        registry.addInterceptor(adminInterceptor).addPathPatterns("/admin/**");


    }

}
